package com.example.demo.common;


import lombok.Data;

@Data
public class ResponseData<T> {
    private String code;
    private String message;
    private T data;

    public ResponseData() {
    }

    public ResponseData(String code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public ResponseData(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public static <T> ResponseData<T> ok(T data){
        return new ResponseData<T>(ResponseEnum.OK.getCode(),ResponseEnum.OK.getMessage(),data);
    }

    public static <T> ResponseData<T> ok(T data,String message){
        return new ResponseData<T>(ResponseEnum.OK.getCode(), message,data);
    }

    public static <T> ResponseData<T> ok(){
        return new ResponseData<T>(ResponseEnum.OK.getCode(),ResponseEnum.OK.getMessage());
    }

    public static <T> ResponseData<T> ok(String message){
        return new ResponseData<T>(ResponseEnum.OK.getCode(), message);
    }

    public static <T> ResponseData<T> fail(){
        return new ResponseData<T>(ResponseEnum.FAIL.getCode(),ResponseEnum.FAIL.getMessage());
    }

    public static <T> ResponseData<T> fail(String code,String message){
        return new ResponseData<T>(code,message);
    }

    public static <T> ResponseData<T> fail(String message){
        return new ResponseData<T>(ResponseEnum.FAIL.getCode(), message);
    }

    public static <T> ResponseData<T> error(String message){
        return new ResponseData<T>(ResponseEnum.ERROR.getCode(), message);
    }
    public static <T> ResponseData<T> delete(){
        return new ResponseData<T>(ResponseEnum.DELETE.getCode(),ResponseEnum.DELETE.getMessage());
    }
    public static <T> ResponseData<T> login(){
        return new ResponseData<T>(ResponseEnum.LOGIN.getCode(),ResponseEnum.LOGIN.getMessage());
    }
    public static <T> ResponseData<T> modify(){
        return new ResponseData<T>(ResponseEnum.MODIFY.getCode(),ResponseEnum.MODIFY.getMessage());
    }
}
